package com.zzyl.controller.manager;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(path = "/nursing/project")
@Api(tags = "护理项目管理")
public class NursingProjectController {

    @Autowired
    private NursingProjectService nursingProjectService;

    @ApiOperation("分页查询护理项目列表")
    @GetMapping(path = "/search")
    public ResponseResult<PageResponse<NursingProjectVo>> findNursingProjectPage(String name, Integer status, Integer pageNum, Integer pageSize){
        return ResponseResult.success(nursingProjectService.findNursingProjectPage(name,status,pageNum,pageSize));
    }

    @ApiOperation("新增护理项目")
    @PostMapping
    public ResponseResult<Void> addNursingProject(@RequestBody NursingProjectDto nursingProjectDto){
        nursingProjectService.addNursingProject(nursingProjectDto);
        return ResponseResult.success();
    }

    @ApiOperation("根据id查询护理项目")
    @GetMapping("/{id}")
    public ResponseResult<NursingProjectVo> findNursingProjectById(@PathVariable Long id){
        return ResponseResult.success(nursingProjectService.findNursingProjectById(id));
    }

    @PutMapping
    @ApiOperation("修改护理项目")
    public ResponseResult<Void> updateNursingProject(@RequestBody NursingProjectDto nursingProjectDto){
        nursingProjectService.updateNursingProject(nursingProjectDto);
        return ResponseResult.success();
    }

    @ApiOperation("删除护理项目")
    @DeleteMapping("/{id}")
    public ResponseResult<Void> deleteNursingProject(@PathVariable Long id){
        nursingProjectService.deleteNursingProject(id);
        return ResponseResult.success();
    }

    @ApiOperation(("禁用/启用护理项目"))
    @PutMapping("/{id}/status/{status}")
    public ResponseResult<Void> updateNursingProjectByStatus(@PathVariable Long id,@PathVariable Integer status){
        nursingProjectService.updateNursingProjectByStatus(id,status);
        return ResponseResult.success();
    }

    @ApiOperation("查询所有护理项目")
    @GetMapping
    public ResponseResult<List<NursingProjectVo>> findAllNursingProject(){
        return ResponseResult.success(nursingProjectService.findAllNursingProject());
    }
}
